package io.osw.modules.approve.service.impl;

import io.osw.common.utils.Constant;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.osw.common.utils.PageUtils;
import io.osw.common.utils.Query;

import io.osw.modules.approve.dao.TblApproveFlowDao;
import io.osw.modules.approve.entity.TblApproveFlowEntity;
import io.osw.modules.approve.service.TblApproveFlowService;


@Service("tblApproveFlowService")
public class TblApproveFlowServiceImpl extends ServiceImpl<TblApproveFlowDao, TblApproveFlowEntity> implements TblApproveFlowService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String flowName = (String)params.get("flowName");
        Page<TblApproveFlowEntity> page = this.selectPage(
                new Query<TblApproveFlowEntity>(params).getPage(),
                new EntityWrapper<TblApproveFlowEntity>()
                        .like(StringUtils.isNotBlank(flowName),"period_name", flowName)
                        .addFilterIfNeed(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))
        );

        return new PageUtils(page);
    }

}
